﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.PopulationUI {
    import flash.events.*;
    import flash.display.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import org.aswing.geom.*;
    import flash.text.*;
    import Display.aswingui.*;

    public class ResourceExplanationDialogView extends GenericDialogView {

        public static const BOTTOM_MARGIN:int = 20;
        public static const BUTTON_PADDING:int = 20;

        protected var m_infoAsset:DisplayObject;
        protected var m_line1:String;
        protected var m_line2:String;
        protected var m_legend:String;

        public function ResourceExplanationDialogView(_arg1:Dictionary, _arg2:String, _arg3:String, _arg4:String, _arg5:String, _arg6:Function=null){
            this.m_line1 = _arg3;
            this.m_line2 = _arg4;
            this.m_legend = _arg5;
            super(_arg1, "", _arg2, TYPE_OK, _arg6);
            this.setLayout(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, 0, SoftBoxLayout.TOP));
        }
        override protected function init():void{
            m_bgAsset = (new (m_assetDict["bg"])() as DisplayObject);
            this.m_infoAsset = (new (m_assetDict["info"])() as DisplayObject);
            this.makeBackground();
            this.makeCenterPanel();
            ASwingHelper.prepare(this);
        }
        override protected function makeBackground():void{
            if (m_bgAsset){
                ASwingHelper.setSizedBackground(this, m_bgAsset, new Insets(0, 0, BUTTON_PADDING));
            };
        }
        override protected function makeCenterPanel():void{
            this.setPreferredSize(new IntDimension(m_bgAsset.width, (m_bgAsset.height + BUTTON_PADDING)));
            this.setMaximumSize(new IntDimension(m_bgAsset.width, (m_bgAsset.height + BUTTON_PADDING)));
            this.setMinimumSize(new IntDimension(m_bgAsset.width, (m_bgAsset.height + BUTTON_PADDING)));
            this.appendAll(this.makeTopPanel(), this.makeBottomPanel(), this.makeAcceptButtonPanel());
            ASwingHelper.prepare(this);
        }
        protected function makeTopPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel();
            _local1.setPreferredSize(new IntDimension(m_bgAsset.width, 225));
            _local1.setMaximumSize(new IntDimension(m_bgAsset.width, 225));
            _local1.setMinimumSize(new IntDimension(m_bgAsset.width, 225));
            _local1.appendAll(this.makeInfoAndClosePanel());
            ASwingHelper.prepare(_local1);
            return (_local1);
        }
        protected function makeInfoAndClosePanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanelVertical();
            _local1.appendAll(this.makeTitleAndClosePanel(), ASwingHelper.verticalStrut(15), this.makeSpacedAdvicePanel());
            ASwingHelper.prepare(_local1);
            return (_local1);
        }
        protected function makeTitleAndClosePanel():JPanel{
            var _local1:JPanel = new JPanel(new BorderLayout());
            var _local2:JPanel = this.makeCloseButtonPanel();
            var _local3:JPanel = createTitlePanel();
            ASwingHelper.prepare(_local2);
            _local1.append(ASwingHelper.horizontalStrut(_local2.getWidth()), BorderLayout.WEST);
            _local1.append(_local3, BorderLayout.CENTER);
            _local1.append(_local2, BorderLayout.EAST);
            var _local4:int = m_bgAsset.width;
            _local1.setPreferredWidth(_local4);
            _local1.setMaximumWidth(_local4);
            _local1.setMinimumWidth(_local4);
            ASwingHelper.prepare(_local1);
            return (_local1);
        }
        protected function makeCloseButtonPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.RIGHT);
            var _local2:JButton = ASwingHelper.makeMarketCloseButton();
            _local2.addEventListener(MouseEvent.CLICK, onCancelX, false, 0, true);
            _local1.append(_local2);
            ASwingHelper.setEasyBorder(_local2, 0, 0, 9, 6);
            ASwingHelper.prepare(_local1);
            return (_local1);
        }
        protected function makeSpacedAdvicePanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel();
            _local1.appendAll(ASwingHelper.horizontalStrut(122), this.makeAdvicePanel());
            ASwingHelper.prepare(_local1);
            return (_local1);
        }
        protected function makeAdvicePanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanelVertical();
            _local1.setPreferredSize(new IntDimension(290, 245));
            _local1.setMaximumSize(new IntDimension(290, 245));
            _local1.setMinimumSize(new IntDimension(290, 245));
            var _local2:AssetPane = ASwingHelper.makeMultilineText(((this.m_line1 + "<br/><br/>") + this.m_line2), 285, EmbeddedArt.DEFAULT_FONT_NAME, TextFormatAlign.LEFT, 18, 0x404040, null, true);
            ASwingHelper.prepare(_local2);
            _local1.appendAll(_local2);
            ASwingHelper.prepare(_local1);
            return (_local1);
        }
        protected function makeBottomPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            _local1.setPreferredSize(new IntDimension(m_bgAsset.width, 95));
            _local1.setMaximumSize(new IntDimension(m_bgAsset.width, 95));
            _local1.setMinimumSize(new IntDimension(m_bgAsset.width, 95));
            var _local2:JPanel = ASwingHelper.makeSoftBoxJPanelVertical();
            _local2.appendAll(ASwingHelper.horizontalStrut(BOTTOM_MARGIN), this.makeInfoText());
            ASwingHelper.prepare(_local2);
            _local1.append(_local2);
            ASwingHelper.prepare(_local1);
            return (_local1);
        }
        protected function makeInfoText():JPanel{
            var _local1:int = m_bgAsset.width;
            var _local2:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            _local2.setPreferredSize(new IntDimension(_local1, 115));
            _local2.setMaximumSize(new IntDimension(_local1, 115));
            _local2.setMinimumSize(new IntDimension(_local1, 115));
            var _local3:AssetPane = ASwingHelper.makeMultilineText(this.m_legend, _local1, EmbeddedArt.DEFAULT_FONT_NAME, TextFormatAlign.CENTER, 14, 0x404040, null, true);
            ASwingHelper.prepare(_local3);
            var _local4:AssetPane = new AssetPane(this.m_infoAsset);
            _local4.setHorizontalAlignment(AsWingConstants.CENTER);
            ASwingHelper.prepare(_local4);
            _local2.appendAll(_local4, _local3);
            return (_local2);
        }
        protected function makeAcceptButtonPanel():JPanel{
            var _local1:JPanel = new JPanel(new FlowLayout(AsWingConstants.CENTER));
            var _local2:CustomButton = new CustomButton(ZLoc.t("Dialogs", "Accept"), null, "GreenButtonUI");
            _local2.addActionListener(onAccept, 0, true);
            _local1.append(_local2);
            ASwingHelper.prepare(_local1);
            return (_local1);
        }

    }
}//package Display.PopulationUI 
